package com.itheima.d7_map_traverse;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * 目标：完成Map集合的案例：统计投票人数。
 *
 */
public class MapDemo4 {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        String [] arr = {"A","B","C","D"};
        Random r =new Random();
        for (int i = 0; i < 80; i++) {
            int j = r.nextInt(arr.length);
            if (map.containsKey(arr[j])) {
                Integer value = map.get(arr[j]);
                map.put(arr[j], value + 1);
            } else {
                map.put(arr[j],1);
            }
        }
         map.forEach((k,v)-> System.out.println(k+"景点的人数："+v));
    }
}
